import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { JwtModule } from '@nestjs/jwt';
import { ConfigService } from '@nestjs/config';
import { UserController } from './user.controller';
import { UserService } from './user.service';
import { AuthService } from './auth.service';
import { User } from './entities/user.entity';
import { UserSocialAuth } from './entities/user-social-auth.entity';
import { JwtAuthService } from '../../common/services/jwt.service';

@Module({
  imports: [
    TypeOrmModule.forFeature([User, UserSocialAuth]),
    JwtModule.registerAsync({
      useFactory: (configService: ConfigService) => ({
        secret:
          configService.get<string>('jwt.accessSecret') || 'access-secret-key',
        signOptions: {
          expiresIn: configService.get<string>('jwt.accessExpiresIn') || '15m',
        },
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [UserController],
  providers: [UserService, AuthService, JwtAuthService],
  exports: [UserService, AuthService],
})
export class UserModule {}
